<template>
  <el-dialog
      width="300"
      title="表格预览"
      :visible.sync="dialogVisible"
      :before-close="handleClose"
      append-to-body>
    <avue-form ref="avueForm" v-model="formModel" :option="option" @submit="submit"></avue-form>
  </el-dialog>
</template>

<script>
import formOption from "@/option/start/formEngine/formOption";
import {deepClone} from "@/utils/util";

export default {
  name: "createForm",
  computed: {
    option() {
      let option = formOption();
      option.boxType = "add";
      return option;
    }
  },
  data() {
    return {
      dialogVisible: false,
      formModel: {}
    }
  },
  methods: {
    show() {
      this.dialogVisible = true
      this.$refs.avueForm.restForm();
    },
    handleClose() {
      this.dialogVisible = false;
      this.formModel = {};
    },
    submit(val, done) {
      let form = deepClone(val);
      this.$emit("submit", form)
      this.handleClose();
      done()
    }

  }
}
</script>

<style scoped>

</style>